package com.tulingxueyuan.order.service.Impl;

import com.tulingxueyuan.order.feignService.StockFeignService;
import com.tulingxueyuan.order.mapper.OrderMapper;
import com.tulingxueyuan.order.service.orderService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class orderServiceImpl implements orderService {

    @Autowired
    StockFeignService stockFeignService;
    @Autowired
    OrderMapper orderMapper;
    @Override
//    @Transactional
    @GlobalTransactional
    public void add() {
        //1.下单业务   省略持久层
        System.out.println("下单成功!");
        orderMapper.add(1);
        //2.扣减库存
        String msg = stockFeignService.reduct();
        System.out.println(msg);
//
//        int i = 1/0;
    }
}
